package com.xidian.zhiancloud.service.riskcontrol.riskevaluate;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xidian.zhiancloud.dao.riskcontrol.riskevaluate.TRiskEvaMethSetFiveFieldMapper;
import com.xidian.zhiancloud.model.riskcontrol.TRiskEvaMethSetConMeasList;
import com.xidian.zhiancloud.model.riskcontrol.TRiskEvaMethSetFiveFieldsList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 风险管控-系统设置-风险评价方法设置-五字段
 */
@Service
public class TRiskEvaMethSetFiveFieldService extends ServiceImpl<TRiskEvaMethSetFiveFieldMapper, TRiskEvaMethSetFiveFieldsList> {

    @Autowired
    TRiskEvaMethSetFiveFieldMapper tRiskEvaMethSetFiveFieldMapper;

    public List<Map<String,String>> getTRiskEvaMethSetFiveFieldsList(
            Long companyid,String evaMethodSetId,String criteria){
        return tRiskEvaMethSetFiveFieldMapper.getTRiskEvaMethSetFiveFieldList
                (companyid,evaMethodSetId,criteria);
    }

    public List<Map<String, Object>> getByEvaMethodSetIdThreeList
            (Long companyId,String evaMethodSetId){
        return tRiskEvaMethSetFiveFieldMapper.getByEvaMethodSetIdThreeList
                (companyId,evaMethodSetId);
    }

    public int addTRiskEvaMethSetFiveField
            (TRiskEvaMethSetFiveFieldsList tREMSetFiveField){
        return tRiskEvaMethSetFiveFieldMapper.
                addTRiskEvaMethSetFiveField(tREMSetFiveField);
    }

    public int updateTRiskEvaMethSetFiveField
            (String id,TRiskEvaMethSetFiveFieldsList tREMSetFiveField){
        return tRiskEvaMethSetFiveFieldMapper.updateTRiskEvaMethSetFiveField
                (id,tREMSetFiveField);
    }

    public int deleteTRiskEvaMethSetFiveField(String id){
        List<String> list = getList(id);
        return tRiskEvaMethSetFiveFieldMapper.deleteTRiskEvaMethSetFiveField(list);
    }

    /**
     * id放入list
     * @param id id(多个已逗号分隔)
     * @return List集合
     */
    public List<String> getList(String id) {
        List<String> list = new ArrayList<String>();
        String[] str = id.split(",");
        for (int i = 0; i < str.length; i++) {
            list.add(str[i]);
        }
        return list;
    }

}
